const baseURL = "http://127.0.0:3000/api/";
 //拼接地址
const request = (options = {}) => {
    //  options
    options = Object.assign(
        {
            method: 'GET',
            data: {},
            header: {},
            dataType: 'json'
        },
        options
    )
    options.url = baseURL + options.url;
    

    return new Promise((resolve, reject) => {
        uni.request({
            url:options.url,
            method:options.method,
            data:options.data,
            dataType:options.dataType,
            header:options.header,
            success:(res)=>{
                resolve(res)
            }
        })
    })
}

request.get =(options)=>{
    return request({
        ...options,
        method:'GET',
    })
}

request.post=(options)=>{
    return request({
        ...options,
        methos:'POST'
    })
}


export default request;